package com.uni.sofia.reader.magazine.test
{
	import com.uni.sofia.reader.magazine.Page;
	
	import flexunit.framework.Assert;
	
	import mx.controls.Image;
	
	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertFalse;
	import org.flexunit.asserts.assertStrictlyEquals;
	import org.flexunit.asserts.assertTrue;
	
	public class PageTest
	{		
		private var page:Page;
		
		private const pageNumber:int = 234;
		private const description:String = "sample description";
		
		[Before]
		public function setUp():void
		{
			page = new Page(pageNumber, description, "time.jpg");
		}
		
		
		[Test(expects='Error')]
		public function testNegativePage():void
		{
			new Page(-23, "123123", "time.jpg");
		}
		
		[Test(expects='Error')]
		public function testNullImage():void
		{
			new Page(3, "123123", null);
		}
		
		[Test]
		public function testEquals():void
		{
			var p:Page = new Page(pageNumber, description, "time.jpg");
			var difPage1:Page = new Page(1, description, "time.jpg");
			var difPage2:Page = new Page(pageNumber, 'no description', "time.jpg");
			
			assertFalse(page.equals(null));
			assertFalse(page.equals(new Number(42)));
		    
			assertTrue(page.equals(page));
			
			assertFalse(page.equals(difPage1));
			assertFalse(page.equals(difPage2));
			
			assertTrue(page.equals(p));
			assertTrue(p.equals(page));
		}
		
	}
}